package com.kh.pajx.sop.dao.sys.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.kh.pajx.sop.base.BaseDaoImpl;
import com.kh.pajx.sop.dao.sys.ISysAreaDao;
import com.kh.pajx.sop.domain.SysArea;
/**
 * 地区编码信息持久化操作实现类
 * 
 * @author:	马兴龙
 */
@Repository
@SuppressWarnings("unchecked")
public class SysAreaDaoImpl extends BaseDaoImpl<SysArea> implements ISysAreaDao{

	/**
     *根据学校的地区id查询地区
     *@param areaCode 区域编码
     */
	@Override
	public SysArea getAreaByCode(String areacode) {
		String hql=" from SysArea t where t.areaCode='"+areacode+"'";
		return (SysArea)getSession().createQuery(hql).list().get(0);
	}
	
/*	@Override
	public List<SysArea> findAll() {
		return getSession().createQuery(//
				"FROM SysArea t where t.areaPid is null  order by t.areaCode asc").list();
	}*/


	@Override
	public List<SysArea> getParentArea()  {
		String hql = " from SysArea s where s.areaPid is null order by s.areaCode asc";
		return this.getSession().createQuery(hql).list();
	}


	@Override
	public List<SysArea> findAreaByCity(String areaCode) {
		// TODO Auto-generated method stub
		return getSession().createQuery(//
				"FROM SysArea t where t.areaPid=? order by t.areaCode asc").setParameter(0, areaCode).list();
	}

}
